home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk168 / stopclick / stopclick.a < prev    next >
Text File  |  1995-03-19  |  11KB  |  330 lines

  1. *   StopClick  version 1.0  for SetCPU1.6 users
  2. *      Written by Ismo Suihko,  August 4, 1990    (isuihko@ujocs.joensuu.fi)
  3. *      Released to the Public Domain
  4. *
  5. *      Routines _GetMMUType and TestFlags are borrowed from SetCPU1.6,
  6. *      which is written by Dave Haynie.
  7. *      Also include file setcpu.i is borrowed from SetCPU sources.
  8. *
  9. * Stops clicking of empty drives by patching 1.3 KS V34.5 ROM (check
  10. * it with command 'version') image loaded in 2-bit RAM with
  11. * 'SetCPU FASTROM'. Disk drive heads will after the patch be stepped
  12. * (silently) in a negative rather than positive direction during the
  13. * regular system checks for a disk change.
  14. * Version 1.6 of SetCPU isn't doing that patch anymore.
  15. * StopClick also fixes trackdisk read/write bug (just like NoClick did).
  16. * This patching is possible, because ROM image isn't protected at all.
  17. * StopClick does nothing, if there isn't MMU and the given address
  18. * doesn't seem to contain right version of the ROM image, so it
  19. * is safe to run this even if you sometimes boot on 68000 mode.
  20. *
  21. * Based on the NoClick program, which is written by Norman Iscove.
  22. * It didn't work on my system, because of SetPatch and TDpatch13
  23. * (TDpatch13 comes with CrossDos (a great product!)).
  24. *
  25. * USAGE:
  26. *   First check the address of the KERNEL by using command 'SetCPU VERBOSE'
  27. *   If you have A2620 or A2630 with 2 MB 32-bit RAM, then output may
  28. *   contain this line
  29. *     KERNEL: (PADDR: $  3a0000) (VADDR: $  fc0000) (SIZE: 256K)
  30. *                       ^^^^^^
  31. *   Then give that address as a parameter to StopClick, like
  32. *     StopClick 3a0000   ;(you can use numbers 0-9 and letters A-F and a-f)
  33. *   Don't put '$' before the address, because it is used by shell.
  34. *   Put StopClick to a startup-sequence after SetCPU FASTROM when you have
  35. *   checked what the address of the KERNEL is. If you add there more memory,
  36. *   you have to check the address again and do modifications if necessary.
  37. *
  38. *   e.g.
  39. *      SetCPU FASTROM
  40. *      stopclick 3a0000    ; KERNEL is at address $3a0000
  41. *
  42. * There aren't any checks if there is a FASTROM image REALLY IN USE.
  43. * We only check, if there are signs of a 1.3 KS V34.2 ROM image..
  44. * If FASTROM has been actice once, but then disactivated, the image could
  45. * still be in the 32-bit RAM, so it is found from there, and patches are
  46. * made but without any effect (and no harm either).
  47. *
  48. * Return codes:
  49. *   0  complete success, fixes made now or they had been made earlier
  50. *   5  no MMU (Memory Management Unit)
  51. *  10  no KS ROM image found, or wrong version of ROM
  52. *  15  KS ROM image found, but modifications couldn't be done??
  53. *  99  invalid parameter
  54. * We get return code 5 always if there isn't a MMU.
  55. *
  56. * BUGS:
  57. *   No known bugs.
  58. *   Maybe the address of KERNEL could be found by this program somehow...
  59. *
  60. * Sometimes clicking will end only after a couple of seconds, just like
  61. * with NoClick. Don't ask me why it happens so, as I don't know.
  62. * And there may be some odd floppy disk drives which don't like to step
  63. * in a negative direction. I haven't yet heard anyone who owns such a drive.
  64. *
  65. * History:
  66. *  V0.9  Jun 23, 1990  works, do we need more?
  67. *  V1.0  Aug 04, 1990  some more checking, now we check if there is a MMU,
  68. *                     earlier we checked only if there was a '020 or better.
  69. *                     program is now 480 bytes long
  70. *  V?.?  ??? ??, ????  will find the address of the ROM image by itself
  71. *
  72. * To compile first get the setcpu.i include file from the SetCPU1.6 sources,
  73. * comment out (add ';'s) the last two lines containing the text
  74. * ;     machine mc68020
  75. * ;             mc68881
  76. * and then compile with commands
  77. *   Assem StopClick.a -o StopClick.o -i INC:
  78. *   Blink StopClick.o to StopClick
  79. * Makefile is also provided for easier compilation and linking.
  80.  
  81.  
  82. * exec.library routines
  83. LVODisable     EQU -120
  84. LVOEnable      EQU -126
  85. LVOCloseLibrary EQU -414
  86. LVOOpenLibrary EQU -552
  87. * dos.library routines
  88. LVOWrite       EQU -48
  89. LVOOutput      EQU -60
  90.  
  91. * some macros, etc.
  92.  include "setcpu.i"
  93.  
  94.  
  95.        movem.l d0/a0,-(sp)     save information of command line parameters
  96.  
  97.        bsr     _GetMMUType
  98.        tst.l   d0              is there a MMU? 68851 or 68030?
  99.        bne.s   scan
  100. * no MMU
  101.        addq.l  #8,sp           forget parameters before quitting
  102.        moveq   #5,d0           no MMU
  103.        bra     exit
  104.  
  105. scan
  106.        movem.l (sp)+,d0/a0
  107. * Now check, if there is a valid hexadesimal address given
  108.        subq.l  #1,d0           take out end of line (null)
  109.        beq.s   scan_err        is there any parameters at all
  110.  
  111.        subq.l  #1,d0           counter (length of the parameter)
  112.        moveq   #0,d1           result
  113.        moveq   #0,d2           character from the command line
  114. scan_loop
  115.        move.b  (a0)+,d2        get a character from the command line
  116.  
  117.        cmpi.b  #' ',d2         check for the end of hex number
  118.        beq.s   scan_ready      is it a space
  119.        cmpi.b  #';',d2
  120.        beq.s   scan_ready      is it a start of a comment
  121.        cmpi.b  #9,d2
  122.        beq.s   scan_ready      is it a tab
  123.  
  124.        moveq   #'0',d3
  125.        cmpi.b  #'9',d2
  126.        ble.s   scan_number
  127.        bclr.l  #5,d2           [a-f] -> [A-F]
  128.        cmpi.b  #'A',d2
  129.        blt.s   scan_err        less than 'A'
  130.        cmpi.b  #'F',d2
  131.        bgt.s   scan_err        greater than 'F'
  132.        moveq   #'A'-10,d3
  133. scan_number
  134.        sub.b   d3,d2
  135.        blt.s   scan_err        less than '0'
  136.        asl.l   #4,d1           multiply by $10
  137.        add.l   d2,d1
  138.        dbra    d0,scan_loop
  139. scan_ready
  140.        tst.w   d1              should be of form xxxx0000
  141.        beq.s   check
  142.  
  143. scan_err
  144.        moveq   #99,d0
  145.        bra.s   exit
  146.  
  147. check
  148.        movea.l d1,a2           address of possible ROM image
  149.  
  150. * Now check if the given address may contain ROM image with exec of V34.2
  151.        cmpi.w  #' 3',$1c(a2)
  152.        bne.s   bad_rom
  153.        cmpi.l  #'4.2 ',$1e(a2)
  154.        bne.s   bad_rom
  155.  
  156. * add offset of trackdisk.device, should be of version 34.1
  157.        adda.l  #$29564,a2
  158.        cmpi.l  #'34.1',$36(a2)
  159.        beq.s   patch
  160. bad_rom
  161.        moveq   #10,d0          no ROM image found
  162.        bra.s   exit
  163.  
  164. patch
  165.        moveq   #2,d7           2 patches
  166. * disable interrupts
  167.        CALLSYS Disable
  168.  
  169. * first we check, if we need to patch, then we check was the patch successful
  170.  
  171. * Stop the clicks
  172. * fix 'bchg #$01,$41(a3)' to 'bset #$01,$41(a3)'
  173.        lea     $104(a2),a0
  174.        cmpi.w  #$086b,(a0)
  175.        bne.s   1$
  176.        move.w  #$08eb,(a0)
  177. 1$
  178.        cmpi.w  #$08eb,(a0)
  179.        bne.s   2$
  180.        subq    #1,d7
  181.  
  182. 2$
  183. * Repair trackdisk read/write bug originally at $feaf9c (1.3)
  184. * fix 'cmp.l $8000,d0' to 'cmpi.l #$8000,d0'
  185.        lea     $1a38(a2),a0
  186.        cmpi.w  #$b0b9,(a0)
  187.        bne.s   3$
  188.        move.w  #$0c80,(a0)
  189. 3$
  190.        cmpi.w  #$0c80,(a0)
  191.        bne.s   4$
  192.        subq    #1,d7
  193. 4$
  194. * enable interrupts
  195.        CALLSYS Enable
  196.  
  197.        move.l  d7,d0           if d7 = 0, patching was succesful
  198.        beq.s   exit
  199.        moveq   #15,d0          patches failed??
  200.  
  201. exit
  202.        tst.b   d0
  203.        beq.s   real_exit
  204.  
  205. * print the usage text
  206.        move.l  d0,-(sp)        push the return code
  207.        lea     dosname(pc),a1
  208.        moveq   #0,d0
  209.        CALLSYS OpenLibrary
  210.        tst.l   d0
  211.        beq.s   2$
  212.        move.l  d0,a5
  213.        exg     a5,a6
  214.        jsr     LVOOutput(a6)
  215.        move.l  d0,d1
  216.        beq.s   1$
  217.        lea     usage(pc),a0
  218.        move.l  a0,d2
  219.        moveq   #usagelen,d3
  220.        jsr     LVOWrite(a6)
  221. 1$
  222.        exg     a5,a6
  223.        move.l  a5,a1
  224.        CALLSYS CloseLibrary
  225. 2$
  226.        move.l  (sp)+,d0        pop the return code
  227.  
  228. real_exit
  229.        rts
  230.  
  231.  
  232.  
  233. * The following routines are borroved from SetCPU1.6 sources.
  234. * I optimized the code a slightly to make my program smaller than 488
  235. * bytes, because otherwise it would have taken 1+2 disk blocks using OFS.
  236. * I removed also the 68040 check, because at this context we don't need
  237. * to know whether there is exactly '030 or '040 as both have MMU.
  238.  
  239.  
  240. ;======================================================================
  241. ;
  242. ;      This routine checks CPU flags early in ExecBase for extended
  243. ;      CPUs that test as a 68020 under 1.3.  If these flags are set,
  244. ;      the actual CPU/MMU type test can be skipped.
  245. ;
  246. ;======================================================================
  247.  
  248. TestFlags:
  249.        moveq.l #0,d0
  250. *       btst.b  #AFB_68040,ATNFLGS(a6)  ; Does the OS think an '040 is here?
  251. *       beq.s   NoEarly40
  252. *       move.l  #68040,d0
  253. *       rts
  254. *NoEarly40:
  255.        btst.b  #AFB_68030,ATNFLGS(a6)  ; Does the OS think an '030 is here?
  256.        beq.s   NoEarly30
  257.        move.l  #68030,d0               ; Sure does...
  258. NoEarly30:
  259.        rts
  260.  
  261.  
  262. ;======================================================================
  263. ;
  264. ;      This function returns 0L if the system contains no MMU,
  265. ;      68851L if the system does contain an 68851, or the CPU number
  266. ;      for CPUs with integral CPUs.
  267. ;
  268. ;      This routine seems to lock up on at least some CSA 68020
  269. ;      boards, though it runs just fine on those from Ronin and
  270. ;      Commodore, as well as all 68030 boards it's been tested on.
  271. ;
  272. ;      ULONG GetMMUType()
  273. ;
  274. ;======================================================================
  275.  
  276. _GetMMUType:
  277.        move.l  4,a6                    ; Get ExecBase
  278.        bsr     TestFlags               ; Check extended CPU types
  279.        tst.l   d0
  280.        beq.s   MMURealTest
  281.        rts
  282.  
  283.        ; For any other machine, a real test must be done.  The test will
  284.        ; try an MMU instruction.  The instruction will fail unless we're
  285.        ; on a "bogus MMU" system, where the FPU responds as an MMU.
  286. MMURealTest:
  287.        movem.l a3/a4/a5,-(sp)          ; Save this stuff
  288.        suba.l  a1,a1
  289.        CALLSYS FindTask                ; Call FindTask(0L)
  290.        move.l  d0,a3
  291.  
  292.        move.l  TC_TRAPCODE(a3),a4      ; Change the exception vector
  293.        lea     MMUTraps(pc),a0
  294.        move.l  a0,TC_TRAPCODE(a3)
  295.  
  296.        moveq.l #-1,d0                  ; Try to detect undecode FPU
  297.        subq.l  #4,sp                   ; Get a local variable
  298.        PMOVE_  tc,(sp)                 ; Let's try an MMU instruction
  299.        addq.l  #4,sp                   ; Return that local
  300.        move.l  a4,TC_TRAPCODE(a3)      ; Reset exception stuff
  301.        movem.l (sp)+,a3/a4/a5          ; and return the registers
  302.        rts
  303.  
  304.        ; This is the exception code.  No matter what machine we're on,
  305.        ; we get an exception.  If the MMU's in place, we should get a
  306.        ; privilige violation; if not, an F-Line emulation exception.
  307. MMUTraps:
  308.        move.l  (sp)+,d0                ; Get Amiga supplied exception #
  309.        cmpi    #11,d0                  ; Is it an F-Line?
  310.        beq.s   MMUNope                 ; If so, go to the fail routine
  311.        move.l  #68851,d0               ; We have MMU
  312.        addq.l  #4,2(sp)                ; Skip the MMU instruction
  313.        rte
  314. MMUNope:
  315.        moveq.l #0,d0                   ; It dinna woik,
  316.        addq.l  #4,2(sp)                ; Skip the MMU instruction
  317.        rte
  318.  
  319.  
  320.  
  321. * some strings
  322.  
  323. dosname dc.b   'dos.library',0
  324. usage  dc.b    'StopClick v1.0 by IS.  '
  325.        dc.b    'Usage: StopClick address-of-1.3-KS-FASTROM-image',10
  326. usagelen EQU   *-usage
  327.  
  328.        END
  329.  
  330.